#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
set<long long> s;
vector<pair<long long, long long>> v;
long long t, x, ans, pre[400005], suf[400005];
int main() {
	freopen("kte.in", "r", stdin);
	freopen("kte.out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> t;
	while(t--) {
		cin >> x;
		if(s.find(x) != s.end())
			s.erase(x);
		else
			s.insert(x);
		auto p = s.begin();
		for(int i = 1; i <= s.size(); i++, p++)
			pre[i] = pre[i - 1] + *p;
		auto p2 = s.rbegin();
		for(int i = 1; i <= s.size(); i++, p2++)
			suf[i] = suf[i - 1] + *p2;
		v.clear(), ans = 0;
		for(int i = 1; i <= s.size(); i++)
			if(pre[i] < suf[i]) {
				if(v.size())
					for(auto &j : v)
						if((j.first > pre[i] && j.first <= suf[i]) || (j.second > pre[i] && j.second <= suf[i])) {
							j.first = min(j.first, pre[i] + 1), j.second = max(j.second, suf[i]);
							goto f;
						}
				v.push_back({pre[i] + 1, suf[i]});
				f:;
			}
		for(auto i : v)
			ans += i.second - i.first + 1;
		cout << ans << '\n';
	}
	return 0;
}